import React from 'react'
import { createBehavior, createResource } from '@designable/core'
import { DnFC, useNodeIdProps } from '@designable/react'
import { createFieldSchema } from '../Field'
import { AllSchemas } from '../../schemas'
import { AllLocales } from '../../locales'
import { FormMonthDayPicker as FormilyFormMonthDayPicker } from '../../customComponents'

export const FormMonthDayPicker: DnFC<
  React.ComponentProps<typeof FormilyFormMonthDayPicker>
> = (props) => {
  const nodeIdProps = useNodeIdProps()
  return (
    <div {...nodeIdProps}>
      <FormilyFormMonthDayPicker {...props} />
    </div>
  )
}

FormMonthDayPicker.Behavior = createBehavior({
  name: 'FormMonthDayPicker',
  extends: ['Field'],
  selector: (node) => node.props['x-component'] === 'FormMonthDayPicker',
  designerProps: {
    propsSchema: createFieldSchema(AllSchemas.FormMonthDayPicker),
  },
  designerLocales: AllLocales.FormMonthDayPicker,
})

FormMonthDayPicker.Resource = createResource({
  icon: 'MonthDay',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'string',
        title: 'FormMonthDayPicker',
        'x-component': 'FormMonthDayPicker',
        'x-decorator': 'FormItem',
        'x-component-props': {},
      },
    },
  ],
})
